<template>
	<view>

		<u-popup :show="show" @close="close" @open="open" mode="center" bgColor="transparent">
			<view class="popup-box">
				<view style="width: 600rpx;height: 640rpx;">
					<view class="popup-top">
						<view style="display: flex;align-items: center;gap: 10rpx;">
							<view class="popup-title">卡券转赠</view>
							<!-- <u-icon name="question-circle-fill" color="#e2e8f0" size="35rpx"
								@click="toPage('/pages/my/giftRules')"></u-icon> -->
						</view>
						<view class="close-btn" @click="close">
							<image @click="close" src="/static/icon-images/close.png" mode="widthFix"></image>
						</view>
					</view>

					<view style="position: relative;">
						<view>
							<view class="input-title">卡券类型</view>
							<view class="input-field input-box" style="justify-content: space-between;">
								<view class="input-text1">{{vipTitleObj.vipName || '卡券'}}</view>
							</view>
						</view>
						
					</view>

					<view>
						<view class="input-title">接收方ID</view>
						<view class="input-field input-box">
							<input class="input-text1" v-model="userInfo.idNumber" placeholder="接收方ID" />
						</view>
					</view>

					<view>
						<view class="input-title">数量</view>
						<view class="input-field input-box">
							<input class="input-text1" v-model="userInfo.number" type="number" min="1" placeholder="输入数量" />
						</view>
					</view>

					<view class="submit-btn" @click="submit">确认转赠</view>

				</view>
			</view>
		</u-popup>

	</view>
</template>

<script>
	import {couponGifting} from '@/api/my.js'
	export default {
		props: {
			show: {
				type: Boolean,
				default: false
			},
			vipTitleObj:{
				type: Object,
				default: null
			}
		},
		data() {
			return {
				checked: '',
				checkShow: false,
				checkList: [{
					text: '合成石'
				}, {
					text: '积分'
				}, {
					text: '大炮'
				}],
				userInfo:{
					idNumber: '',
					number: '',
					vipCardId: 0
				}
			};
		},
		methods: {
			open() {
				this.$emit('update:show', true)
			},
			close() {
				this.$emit('success')
				this.userInfo={}
			},
			check() {
				this.checkShow = !this.checkShow
			},
			checkItem(text) {
				this.checked = text
				this.checkShow = false
			},
			toPage(url) {
				uni.navigateTo({
					url
				})
			},
			async submit() {
				if(!this.userInfo.idNumber){
					uni.showToast({
						title:'请输入接收方ID',
						icon:'none'
					})
					return
				}
				if(!this.userInfo.number){
					uni.showToast({
						title:'请输入转赠能量',
						icon:'none'
					})
					return
				}
				
				// if(this.userInfo.number <= 0){
				// 	uni.showToast({
				// 		title:'转赠数量需要大于0',
				// 		icon:'none'
				// 	})
				// 	return
				// }
				this.userInfo.vipCardId = this.vipTitleObj.vipCardId
				let res = await couponGifting(this.userInfo)
				this.userInfo={}
				this.$emit('success')
				uni.showToast({
					title:'转赠成功',
					icon:'none'
				})
			}
		}
	}
</script>

<style lang="scss">
	.popup-box {
		background: linear-gradient(135deg, #0a1a3a 0%, #050a1a 100%);
		border: 1rpx solid rgba(255, 255, 255, 0.15);
		border-radius: 20rpx;
		overflow-y: auto;
		padding: 30rpx;
	}

	.popup-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.popup-title {
		font-weight: 700;
		font-size: 38rpx;
		line-height: 1;
		color: #e2e8f0;
	}

	.close-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.15);

		image {
			display: block;
			width: 28rpx;
			height: 28rpx;
		}
	}

	.input-title {
		font-size: 28rpx;
		color: #e2e8f0;
		line-height: 1;
		margin: 20rpx 0;
	}

	.input-box {
		display: flex;
		align-items: center;
		min-height: 85rpx;
	}

	.input-text1 {
		font-size: 32rpx;
		color: #e2e8f0;
		display: flex;
		align-items: center;
		text-align: left;
		// line-height: 1;
	}

	.submit-btn {
		background: #ff6b6b;
		color: white;
		border: none;
		border-radius: 20rpx;
		padding: 20rpx 40rpx;
		font-weight: 600;
		font-size: 36rpx;
		box-shadow: 0 4rpx 20rpx rgba(255, 62, 62, 0.6);
		position: relative;
		overflow: hidden;
		transition: all 0.3s ease;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 35rpx;
	}

	.check-box {
		margin-top: 5rpx;
		position: absolute;
		z-index: 2;
		width: 100%;
		border-radius: 10rpx;
		background-color: #1f2937;
	}

	.check-item {
		padding-left: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		height: 70rpx;
		font-size: 32rpx;
		color: #e2e8f0;
	}
</style>